package com.taoge.p4.common.rabbit;

import com.taoge.p4.common.rabbit.constant.QueueConstant;
import com.taoge.p4.common.rabbit.exchange.RabbitmqExchange;
import com.taoge.p4.common.rabbit.producer.RabbitmqProducer;
import com.taoge.p4.common.rabbit.routingKey.BrandRoutingKey;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(RabbitmqExchange.BRAND_EXCHANGE.name());
    }

    @Bean
    public Queue queue(){
        return new Queue(QueueConstant.BRAND_QUEUE_NAME);
    }

//    @Bean
//    public Queue brandQueue(){
//        return new Queue(QueueConstant.BRAND_QUEUE_NAME);
//    }

    @Bean
    public Binding binding(){
        return BindingBuilder.bind(queue()).to(topicExchange()).with(BrandRoutingKey.BRAND_STATUS.getKey());
    }
}
